﻿$(document).ready(function () {
    

    PageClickFunc(1);
    $("#btnSele").click(function () {
        InitUserList(1)
    });

    $("#txtIMSI").focus(function () {
        if ($(this).val() == "输入IMSI查询") {
            $(this).val("");
        }
    })

    $("#txtIMSI").blur(function () {
        if ($(this).val() == "") {
            $(this).val($(this).attr("default"));
        }

    })

    $("#txtUserAccount").focus(function () {
        if ($(this).val() == "输入用户账号") {
            $(this).val("");
        }
    })

    $("#txtUserAccount").blur(function () {
        if ($(this).val() == "") {
            $(this).val($(this).attr("default"));
        }

    })

})
PageClickFunc = function (pageclickednumber) {
    InitUserList(pageclickednumber);
}
function InitUserList(pageclickednumber) {
    var IMSI = $("#txtIMSI").val() == $("#txtIMSI").attr("default") ? "" : $("#txtIMSI").val();
    var sysAccount = $("#txtAccount").val() == $("#txtAccount").attr("default") ? "" : $("#txtAccount").val();

    $.ajax({
        type: "post",
        data: { action: "GetList", pageIndex: pageclickednumber, pageSize: pageSize, IMSISELE: IMSI, sysAccount: sysAccount, userAccount: userAccount },
        datatype: "json",
        url: "../../Ajax/UserAjax.ashx",
        beforSend: function () {
        },
        success: function (data) {
            if (data != null) {
                var json = $.parseJSON(data).json;
                var tbody = "";
                var pageCount = $.parseJSON(data).flag;
                $.each(json, function (k, v) {
                    tbody += "<tr>"
                    tbody += "<td><lable name='lblId' id='lbl" + k + "'>";
                    tbody += v.ID;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblAcccount'>";
                    tbody += v.UserAccount;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblUserName' id='" + v.UserInfoID + "'>";
                    tbody += v.UserName;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblCommunicationID' id='" + v.Pid + "'>";
                    tbody += v.PName;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblIsRobot' >";
                    tbody += v.IsRobot;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblState' id='" + v.State + "'>";
                    tbody += stateName
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblRegisterTime'>";
                    tbody += v.RegisterTime;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblIMSI'>";
                    tbody += v.IMSI;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblIMEI'>";
                    tbody += v.IMEI;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblNumber'>";
                    tbody += v.Number;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblArea'>";
                    tbody += v.Area;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblPlmn'>";
                    tbody += v.Plmn;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblMac'>";
                    tbody += v.Mac;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblInviteUserID'>";
                    tbody += v.InviteUserID;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblInviteScore'>";
                    tbody += v.InviteScore;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblInviteTotalScore'>";
                    tbody += v.InviteTotalScore;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblInviteSuccessNum'>";
                    tbody += v.InviteSuccessNum;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblInviteTime'>";
                    tbody += v.InviteTime == "0001/1/1 0:00:00" ? "" : v.InviteTime;
                    tbody += "</lable></td>";
                    tbody += "<td><lable name='lblPrice'>";
                    tbody += v.Price;
                    tbody += "</lable></td>";
                    tbody += "<td>";
                    tbody += "<input type='button' onclick='Update(this)' value='更新'><input type='button' onclick='Delete(this)' value='删除'>"
                    if (v.IsRobot == "True")
                        tbody += "<input type='button' onclick='UpdateUserName(this)' value='更改用户名'>"
                    tbody += "</td>";
                    tbody += "</tr>"
                })
                $("#tb1").empty().append(tbody);
                $("#pager").pager({ pagenumber: pageclickednumber, pagecount: Math.ceil(pageCount / pageSize), buttonClickCallback: PageClickFunc });
            }
        },
        complete: function () {
        },
        error: function () {
        }
    })
}
